//
//  MZYBaseViewController.m
//  WristWatch
//
//  Created by dllo on 15/10/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MZYBaseViewController.h"
#import "MZYHeader.h"

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface MZYBaseViewController ()

@end

@implementation MZYBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self network];
    // navigation颜色
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:32 / 255.0 green:34 / 255.0 blue:39 / 255.0 alpha:1]];
    
}


#pragma mark -网络状态判断
- (void)network {
    // 检测网络情况
    AFNetworkReachabilityManager *manage = [AFNetworkReachabilityManager sharedManager];
    
    // 开始检测
    [manage startMonitoring];
    [manage setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        //        if (status == 0 || status == -1) {
        //            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"网络异常" message:@"请查看网络状况" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        //            [alertView show];
        //            [alertView release];
        //        }
        //    }];
        switch (status) {
            case AFNetworkReachabilityStatusReachableViaWWAN:
                NSLog(@"4G连接");
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                NSLog(@"WIFI连接");
                break;
            case AFNetworkReachabilityStatusNotReachable: {
                UIAlertView *altView = [[UIAlertView alloc] initWithTitle:@"无网络" message:@"请检查网络" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [altView show];
                [altView release];
                NSLog(@"无连接或者3G网络及2G网络");
            } break;
            case AFNetworkReachabilityStatusUnknown:{
                
            }
                NSLog(@"连接状态未知");
                
                break;
        }
    }];
    
    [manage stopMonitoring];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
